package practice4;

import java.util.Scanner;

public class P2309 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int K=sc.nextInt();
		sc.nextLine();			//读取换行，防报错
        String str=sc.nextLine();
        String[] strings=str.split("\\s+|\\.");  //按照" "和"."划分字符串
        int count=0;
        //遍历字符串,从Alice->Bob
        for(int i=0;i<strings.length;i++) {
            if(strings[i].equals("Alice")) {
                //找到了Alice,往后找Bob
                int length=0;
                for(int j=i+1;j<strings.length;j++) {
                    if(strings[j].equals("Bob")) {
                        //找到了Bob
                        length+=(j-i);		//加上分隔符的长度
                        if(length<=K) {
                            count++;
                        }
                    }
                    length+=strings[j].length();
                }
            }
        }

        //遍历字符串,从Bob->Alice
        for(int i=0;i<strings.length;i++) {
            if(strings[i].equals("Bob")) {
                //找到了Bob,往后找Alice
                int length=0;
                for(int j=i+1;j<strings.length;j++) {
                    if(strings[j].equals("Alice")) {
                        //找到了Alice
                        length+=(j-i);		//加上分割符的长度
                        if(length<=K) {
                            count++;
                        }
                    }
                    length+=strings[j].length();
                }
            }
        }
        System.out.println(count);
    }
}
